import request from '@/utils/http'
import type { Login_params, register_params, getVerifyCode_params } from './index.type'

// 获取商户id
export const getTenantId = (website: string) => {
  return request.get({
    url: '/admin-api/system/tenant/get-by-website',
    data: { website },
    custom: {
      title: '获取商户id'
    }
  })
}

// 登录
export const miniLogin = (params: Login_params) => {
  return request.post({
    url: '/admin-api/system/auth/social-login',
    data: params,
    custom: {
      title: '微信登录'
    }
  })
}

// 绑定手机号
export function register(data: register_params) {
  return request.post({
    url: '/admin-api/system/auth/sms-login',
    data,
    custom: {
      title: '绑定手机号'
    }
  })
}

// 获取验证码
export function getVerifyCode(data: getVerifyCode_params) {
  return request.post({
    url: '/admin-api/system/auth/send-sms-code',
    data,
    custom: {
      title: '获取验证码'
    }
  })
}

// 获取客户信息
export function getCustomerInfo() {
  return request.get({
    url: '/admin-api/system/user/profile/get',
    custom: {
      title: '获取用户信息'
    }
  })
}

// 刷新令牌
export function resetToken(refreshToken) {
  return request.post({
    url: `/admin-api/system/auth/refresh-token?refreshToken=${refreshToken}`,
    custom: {
      title: '刷新令牌'
    }
  })
}
